#ifndef WS2812B_H
#define WS2812B_H
#include "at32f4xx.h"
#include "stdint.h"
#include "stdlib.h"
//#include "math.h"
//TIM3-CH1  PA6	MISO
#define WS2812B_PIN		GPIO_Pin_2
#define WS2812B_PORT	GPIOA

#define WS2812B_ARR 	60
#define T0H		20
#define T1H		40

#define LED_NUM		27
#define DATA_SIZE	24



extern uint16_t Single_LED_Buffer[DATA_SIZE*LED_NUM + 1];
extern uint32_t LED_Buffer[LED_NUM];
extern uint16_t ColorLight_Time;

typedef struct Ws2812b_param {
    uint8_t mode;           
    uint16_t color_mask;
    uint8_t brightness;
    uint8_t min_brightness;
    uint16_t time_conter;
    FunctionalState state;
}Ws2812b_param_t;


void PWM_WS2812B_Init(uint16_t arr);
void TIMx_Cmd(FunctionalState NewState);
void TIMx_SetCompare4(uint16_t Value);
void DMA_Start(uint16_t DataNumber);
void WS2812B_Init(void);
void WS2812B_ClearBuf(void);

void PWM_WS2812B_Write_24Bits(void);
void PWM_WS2818B_Write_buf(uint32_t color);

void WhiteLight_Brightness_0(uint8_t time_counter);
void WhiteLight_Brightness_1(uint8_t time_counter);
void WhiteLight_Brightness_2(uint8_t time_counter);
void Color_Light_Mode_0(uint16_t time_counter, uint16_t color_mask,uint8_t brightness, uint8_t min_brightness);
void Color_Light_Mode_1(uint8_t time_counter);
void Color_Light_Mode_2(uint8_t time_counter);
void Color_Light_Mode_3(uint8_t time_counter);
void Light_Mode(uint8_t mode,uint16_t time_counter,FunctionalState state);

void Blue_Breathe_Light(uint8_t time_counter);
void Red_Breathe_Light(uint8_t time_counter);
void Green_Breathe_Light(uint8_t time_counter);
void Purple_Breathe_Light(uint8_t time_counter);
void Cyan_Breathe_Light(uint8_t time_counter);
void Yellow_Breathe_Light(uint8_t time_counter);
void White_Breathe_Light(uint8_t time_counter);
void Orange_Breathe_Light(uint8_t time_counter);
void Work_Breathe_Mode(uint8_t mode,uint16_t time_counter,FunctionalState state);

void Colour_Brightness_Choose_Mode(uint8_t mode,uint8_t brightness,FunctionalState state);

void Ws2812b_Color(uint8_t mode,uint16_t color_mask, uint8_t brightness,uint8_t min_brightness, uint16_t time_counter,FunctionalState state);

void Deal_Time_Set(void);
#endif
